<style>
	.c-index-wrapper {
		box-sizing: content-box;
		padding: 15px;
		/* height: 100%;
		background: url('../../../dist/style/res/user/loginBg.png') no-repeat left top; 
		background-size: cover; */
	}
	.c-index-middle-map {
		height: 100%;
	}
	.c-index-leftTop {
		height: 49%;
		background-color: #DEE9F5;
		overflow-y: auto;
		overflow: hidden;
	}
	.line-split {
		width: 100%;
		height: 1%;
	}
	.c-index-bottom {
		height: 50%;
		background-color: #DEE9F5;
		overflow-y: auto;
		overflow: hidden;
	}
	.c-index-rightTop {
		height: 49%;
		background-color: #DEE9F5;
		overflow-y: auto;
		overflow: hidden;
	}
	.c-index-rightbottom {
		height: 50%;
		background-color: #DEE9F5;
		overflow-y: auto;
		overflow: hidden;
	}
	.layui-tab-card .layui-tab-content{
		padding: 0;
	}
	.layui-tab-card .layui-text{
		float: right;
		margin: 10px 20px 0 0;
		cursor: pointer;
		user-select: none;
		-moz-user-select: none;
	}
	.no-data-tips{
		margin-top: 100px;
	}
</style>
<div class="c-index-wrapper">
	<div style="width:100%; height: 100%; margin:0 auto;"> 
		<!-- <div style="width:350px; float:left; height: 100%;">
			<div id="i-index-left-top" class="layui-col-md12 c-index-leftTop">
			</div>
			<div class="layui-col-md12 line-split"></div>
			<div id="i-index-left-bottom" class="layui-col-md12 c-index-bottom">
			</div>
		</div>
		<div style="width:350px; float:right;height: 100%;">
			<div id="i-index-right-top" class="layui-col-md12 c-index-rightTop">
			</div>
			<div class="layui-col-md12 line-split"></div>
			<div id="i-index-right-bottom" class="layui-col-md12 c-index-rightbottom">
			</div>
		</div>
		<div id="i-index-middle-map" class="c-index-middle-map" style="margin-left:350px;margin-right:350px;"></div> -->
		<div class="layui-tab layui-tab-card">
			<ul class="layui-tab-title layui-clear">
				<li class="layui-this">待办事项<span class="layui-badge taskAmount"></span></li>
				<span class="layui-text T-btn" data-target="more">更多>></span>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show">
					<table id="todoList-table" lay-filter="todoList-table-filter">
						
					</table>
				</div>
			  </div>
		</div>
	</div>
</div>

<!-- 任务列表状态栏 -->
<script type="text/html" id="state">
    {{#
		var getStatusColor = function() {
			var mapColors = {
                '00': 'layui-bk-green',
                '20': 'layui-bk-gray',
                '25': 'layui-bk-orange',
                '30': 'layui-bk-green',
                '40': 'layui-bk-orange',
                '90': 'layui-bk-gray',
                '99': 'layui-bk-gray'
			};
			return mapColors[d.state] || '';
		};
	}}
	<span class="custom-badge {{getStatusColor()}}">{{d.statename}}</span>	
</script>

<script>
layui.use(['admin', 'form', 'user', 'element', 'table', 'tools'], function(){
    var $ = layui.$,
    setter = layui.setter,
    admin = layui.admin,
	form = layui.form,
	view = layui.view,
    router = layui.router(),
	search = router.search,
	element = layui.element,
	table = layui.table,
	tools = layui.tools,
	layout = ['.layui-table th', '.layui-table td', '.my-header-setapp', '.user-info'];

	initTodoList();

	// if(router.search.more && router.search.more == 1){
	// 	view('i-index-left-top').render('./IndexPage/daiBan', {show: '1'})
    // }else{
	// 	view('i-index-left-top').render('./IndexPage/daiBan');
	// }
	// view('i-index-left-top').render('./IndexPage/daiBan');
	// view('i-index-left-bottom').render('./IndexPage/wancheng');
	// view('i-index-right-top').render('./IndexPage/taskShow');
	// view('i-index-right-bottom').render('./IndexPage/taskorder');
	// view('i-index-middle-map').render('./IndexPage/map');

	//加载待办事项表格
	function initTodoList(){
		admin.req({
			url: 'myapi/DC/api/rest/web/custom/BacklogHome',
			success: function(res){
				if(res.retcode == '0'){
					var taskList = res.data.sumTask,
						taskAmount = res.data.taskAmount || 0;
					$('.taskAmount').empty().html(taskAmount);
					table.render({
						elem: '#todoList-table',
						cols: [[
							{ type: 'numbers', title: '序号', align: 'center', width: 44 },
							{ field: 'state', title: '任务状态', align: 'center', templet: '#state', width: 105},
							{ field: 'tasktypename', title: '任务类型', align: 'center' },
							{ field: 'taskname', title: '任务名称',
								templet: function(d){
									return '<span lay-tips="'+d.taskname+'">'+d.taskname+'</span>'
								}
							},
							{ field: 'starttime', title: '任务开始时间', align: 'center', width: 165 },
							{ field: 'endtime', title: '任务结束时间', align: 'center', width: 165 },
							{ field: 'remaintime', title: '距结束还有', align: 'center' },
							{ field: 'deptname', title: '任务发布单位', align: 'center', width: 150 },
							{ field: 'username', title: '发布人', align: 'center', width: 150 }
						]],
						skin: 'nob',
						height: 800,
						initSort: {
							field: 'starttime',
							type: 'asc' 
						},
						even: true,
						limit: 5000,
						data: taskList,
						done: function(res, curr, count){
							DataTipsShow(count);
							tools.setFont(layout);
						}
					});
				}
			}
		});
	}

	function DataTipsShow(count){
		var nodataTips = '<div class="no-data-tips"><img src="/src/style/res/about/empty.png"><p style="color:#DBDBDB;">暂无数据</p></div>';
		count === 0 ? $('.layui-table-body').html(nodataTips) : $('.layui-table-body .no-data-tips').remove();
	}

	//点击事件
	$('.c-index-wrapper').delegate('.T-btn', 'click', function(){
		var target = $(this).data('target');
		switch(target){
			case 'more':
				layer.open({
					id: 'missionSearch',
					title: '<i class="formFill-icon"></i><span style="color:#FFF;">待办事项</span>',
					offset: '100px',
					type: 1,
					shadeClose: true,
					resize: false,
					area: ['1133px', '659px'],
					success: function(lay, index){
						view(this.id).render('./IndexPage/components/missionTable', { layerIndex: index });
					}
				});
				break;
			default:
				break;
		}
	});

	//监听行单双击事件
	table.on('row(todoList-table-filter)', function(obj){
		var temUrl = obj.data.connection ? '/'+obj.data.connection+'/taskid='+obj.data.taskid : ''; 
		$.each($("#LAY-system-side-menu .my-memu-text"),function(index,item){
			if( $(item).text()=="审核管理"){ 
				$(item).parents("li").addClass("layui-nav-itemed").siblings().removeClass("layui-nav-itemed")
			} 
		})
		location.hash = temUrl;
	});

});
</script>

